<?php

/**
 * 默认控制器
 */
class Controller_Jqueryplugin extends Controller_Abstract
{
	function actionIndex()
	{
		$page = $this->_context->get('page', 1);
		$type_id = $this->_context->get('type_id', null);
    	
    	$jqueryPlugins = Jqueryplugins::model()->paginationGetAll($page, $type_id);
    	$pagination = new Pagination($jqueryPlugins['totalCount'], url($this->_context->requestUDI(false), array('type_id' => $type_id)), $page, JQUERYPLUGINS_LIST_PERPAGE);
		unset($jqueryPlugins['totalCount']);;
    	fdump($jqueryPlugins);
    	$this->_view['jqueryPlugins'] = $jqueryPlugins;
    	$this->_view['pagination'] = $pagination->render();
	}
	
    function actionDetail()
    {
        $id = $this->_context->get('id', null);
    	if($id){
    		$jqueryPluginsModel = new jqueryPlugins();
    		$jqueryPlugin = $jqueryPluginsModel->find('*', array('id' => $id), null, null, array('onlyOne' => true, 'replaceDescriptionVars' => true, 'htmlSpecialcharsPreContent' => true));
    		
    		if(empty($jqueryPlugin)){
    			die('没找到相应ID的Jqueryplugin模板,跳转到404页面');
    			exit();
    		}
	    	if(file_exists(iconv('UTF-8', 'GB2312', JQUERYPLUGINS_DIR . DIRECTORY_SEPARATOR . $jqueryPlugin['root_foldername'] . DIRECTORY_SEPARATOR . $jqueryPlugin['download_pack']))){
	    		$this->_view['download_pack'] = $jqueryPlugin['download_pack'];
	    	}
    		
    		$this->_view['jqueryPlugin'] = $jqueryPlugin;
    	}
    }
    
}

